import urllib.request
import random
proxes_pools=[
    {'http':'172.16.17.32:80'},
    {'http':'218.87.205.20:15346'}
]


proxies=random.choice(proxes_pools)
url='http://www.baidu.com/s?wd=ip'

headers={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}

request=urllib.request.Request(url,headers=headers)
handler=urllib.request.ProxyHandler(proxies=proxies)
opener=urllib.request.build_opener(handler)
response=opener.open(request)
content=response.read().decode('utf-8')
with open('ips.txt','w',encoding='utf-8') as f:
    f.write(content)
    f.close()